# coding=utf-8

import requests, schedule, time


def do_request(_url, _cookie):
    countdown = 10
    while countdown > 0:
        r = requests.get(_url, cookies=_cookie)
        countdown = countdown - 1
        print(countdown)
    resp = r.text
    print(resp)


cookie_str = '''__jda=210497302.1725009527323158724550.1725009527.1731137056.1731146742.7'''

lists = cookie_str.split(';')
_cookie = {}
for i in lists:
    j = i.strip()
    j = j.split('=')
    _cookie[j[0]] = j[1]

_url = "https://coupon.m.jd.com/coupons/show.action?key=c4m2c4s3oaa242698f611497ec05a32b&roleId=174386708&to="


def job():
    print("I'm working...")
    print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
    # do_request(_url, _cookie)


# schedule.every().minutes.do(job)
#实际操作可以提前一分钟，并且延长countdown
schedule.every().day.at("20:00").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)
